import 'package:json_annotation/json_annotation.dart';

@JsonSerializable()


class Group {
  String name;
  String email;
  List<Friends> friends;

  Group({this.name, this.email, this.friends});

  Group.fromJson(Map<String, dynamic> json) {
    name = json['name'];
    email = json['email'];
    if (json['friends'] != null) {
      friends = new List<Friends>();
      json['friends'].forEach((v) {
        friends.add(new Friends.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['name'] = this.name;
    data['email'] = this.email;
    if (this.friends != null) {
      data['friends'] = this.friends.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class Friends {
  String name;
  String email;

  Friends({this.name, this.email});

  Friends.fromJson(Map<String, dynamic> json) {
    name = json['name'];
    email = json['email'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['name'] = this.name;
    data['email'] = this.email;
    return data;
  }
}
//    String jsonStr='[{"name":"Jack"},{"name":"Rose"}]';
//    String group='{"name":"John Smith","email": "john@example.com","friends": [{"name": "Jack","email": "Jack@example.com"},{"name": "Nancy","email": "Nancy@example.com"}]}';
//    print(jsonStr);
//    Map<String ,dynamic> map = json.decode(group);
//    Group user = Group.fromJson(map);
//    List item = user.friends;
//    Friends friend = item.first;
//    print(user.name);
//    print(friend.name);

class Classify {
  List<Male> male;
  List<Male> female;
  List<Male> picture;
  List<Male> press;
  bool ok;

  Classify({this.male, this.female, this.picture, this.press, this.ok});

  Classify.fromJson(Map<String, dynamic> json) {
    if (json['male'] != null) {
      male = new List<Male>();
      json['male'].forEach((v) {
        male.add(new Male.fromJson(v));
      });
    }
    if (json['female'] != null) {
      female = new List<Male>();
      json['female'].forEach((v) {
        female.add(new Male.fromJson(v));
      });
    }
    if (json['picture'] != null) {
      picture = new List<Male>();
      json['picture'].forEach((v) {
        picture.add(new Male.fromJson(v));
      });
    }
    if (json['press'] != null) {
      press = new List<Male>();
      json['press'].forEach((v) {
        press.add(new Male.fromJson(v));
      });
    }
    ok = json['ok'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    if (this.male != null) {
      data['male'] = this.male.map((v) => v.toJson()).toList();
    }
    if (this.female != null) {
      data['female'] = this.female.map((v) => v.toJson()).toList();
    }
    if (this.picture != null) {
      data['picture'] = this.picture.map((v) => v.toJson()).toList();
    }
    if (this.press != null) {
      data['press'] = this.press.map((v) => v.toJson()).toList();
    }
    data['ok'] = this.ok;
    return data;
  }
}

class Male {
  String name;
  int bookCount;
  int monthlyCount;
  String icon;
  List<String> bookCover;

  Male(
      { this.name,
        this.bookCount,
        this.monthlyCount,
        this.icon,
        this.bookCover});

  Male.fromJson(Map<String, dynamic> json) {
    name = json['name'];
    bookCount = json['bookCount'];
    monthlyCount = json['monthlyCount'];
    icon = json['icon'];
    bookCover = json['bookCover'].cast<String>();
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['name'] = this.name;
    data['bookCount'] = this.bookCount;
    data['monthlyCount'] = this.monthlyCount;
    data['icon'] = this.icon;
    data['bookCover'] = this.bookCover;
    return data;
  }
}

class ClassifyItem {
  bool ok;
  List<Books> books;
  int total;

  ClassifyItem({this.ok, this.books, this.total});

  ClassifyItem.fromJson(Map<String, dynamic> json) {
    ok = json['ok'];
    if (json['books'] != null) {
      books = new List<Books>();
      json['books'].forEach((v) {
        books.add(new Books.fromJson(v));
      });
    }
    total = json['total'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['ok'] = this.ok;
    if (this.books != null) {
      data['books'] = this.books.map((v) => v.toJson()).toList();
    }
    data['total'] = this.total;
    return data;
  }
}

class Books {
//  double retentionRatio;
  bool allowMonthly;
  String sId;
  String majorCate;
  String author;
  String superscript;
  String lastChapter;
  int banned;
  String minorCate;
  String title;
  String contentType;
  String cover;
  String site;
  List<String> tags;
  int sizetype;
  int latelyFollower;
  String shortIntro;

  Books(
      { //this.retentionRatio,
        this.allowMonthly,
        this.sId,
        this.majorCate,
        this.author,
        this.superscript,
        this.lastChapter,
        this.banned,
        this.minorCate,
        this.title,
        this.contentType,
        this.cover,
        this.site,
        this.tags,
        this.sizetype,
        this.latelyFollower,
        this.shortIntro});

  Books.fromJson(Map<String, dynamic> json) {
//    retentionRatio = json['retentionRatio'];
    allowMonthly = json['allowMonthly'];
    sId = json['_id'];
    majorCate = json['majorCate'];
    author = json['author'];
    superscript = json['superscript'];
    lastChapter = json['lastChapter'];
    banned = json['banned'];
    minorCate = json['minorCate'];
    title = json['title'];
    contentType = json['contentType'];
    cover = json['cover'];
    site = json['site'];
    tags = json['tags'].cast<String>();
    sizetype = json['sizetype'];
    latelyFollower = json['latelyFollower'];
    shortIntro = json['shortIntro'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
//    data['retentionRatio'] = this.retentionRatio;
    data['allowMonthly'] = this.allowMonthly;
    data['_id'] = this.sId;
    data['majorCate'] = this.majorCate;
    data['author'] = this.author;
    data['superscript'] = this.superscript;
    data['lastChapter'] = this.lastChapter;
    data['banned'] = this.banned;
    data['minorCate'] = this.minorCate;
    data['title'] = this.title;
    data['contentType'] = this.contentType;
    data['cover'] = this.cover;
    data['site'] = this.site;
    data['tags'] = this.tags;
    data['sizetype'] = this.sizetype;
    data['latelyFollower'] = this.latelyFollower;
    data['shortIntro'] = this.shortIntro;
    return data;
  }
}
